import java.util.UUID;

public class Test {


    public static void main(String[] args) {

        MyLooper.prepare();

        MyHandler handler=new MyHandler(){
            @Override
            public void handmessage(MyMessage msg) {
                super.handmessage(msg);
                System.out.println(msg.what+"---->"+msg.object.toString());

            }
        };
        new Thread(new Runnable() {
            @Override
            public void run() {
                MyMessage myMessage=new MyMessage();
                myMessage.what=1;
                myMessage.object=Thread.currentThread().getName()+"---"+ UUID.randomUUID();

                handler.sendMessage(myMessage);
                try {
                    Thread.sleep(30000);
                    MyMessage myMessages=new MyMessage();
                    myMessages.what=2;
                    myMessages.object=Thread.currentThread().getName()+"---"+ UUID.randomUUID();

                    handler.sendMessage(myMessages);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        MyLooper.loop();

    }
}
